/* Copyright (c) 2010-2020 Vadim Surov.
 */
package com.srv.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Set implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2889325669118827387L;

	private static int KEY = 0;

	private String key;
	private List<Card> cards = new ArrayList<Card>();

	public Set(List<Card> cards) {
		this.setKey(""+(KEY++));
		this.setCards(cards);
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public List<Card> getCards() {
		return cards;
	}

	public void setCards(List<Card> cards) {
		this.cards = cards;
	}

	public Set copy() {
		final List<Card> cards = getCards();
		final List<Card> newList = new ArrayList<Card>(cards.size());
		for (Card card : cards)
			newList.add(card.copy());
		return new Set(newList);	
	}
	
	public String getHtml(String name) {
		return cards.get(0).getHtml(name);		
	}		
	
	public String getToolIcon() {
		return "<div style=\"width:100%; border-style:solid double double solid; " +
				"border-color:lightgrey; border-width:3px;\">" + 
				getHtml("set_"+new Date().getTime()) + "</div>";
	}

	public String getDragIcon() {
		return "<table style=\"border-style:solid double double solid; " +
				"border-color:lightgrey; border-width:3px;\"><tr><td>" + 
				getHtml("set_"+new Date().getTime()) + "</td></tr></table>";
	}
}
